package com.example.gitpart03.Type;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.gitpart03.R;

import java.util.ArrayList;
import java.util.List;

public class TypeFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_type, container, false);

        // 左边ListView
        ListView typeLeftList = view.findViewById(R.id.type_leftList);
        List<TypeLeftItem> leftDataList = new ArrayList<>();
        leftDataList.add(new TypeLeftItem("酸奶"));
        leftDataList.add(new TypeLeftItem("牛奶"));
        leftDataList.add(new TypeLeftItem("奶酪"));
        leftDataList.add(new TypeLeftItem("黄油"));
        leftDataList.add(new TypeLeftItem("奶粉"));
        leftDataList.add(new TypeLeftItem("冰淇淋"));

        TypeLeftAdapter leftAdapter = new TypeLeftAdapter(
                getContext(),
                R.layout.type_left_list,
                leftDataList
        );
        typeLeftList.setAdapter(leftAdapter);

        // 右边ListView
        ListView typeRightList = view.findViewById(R.id.type_rightList);
        List<TypeRightItem> rightDataList = new ArrayList<>();

        rightDataList.add(new TypeRightItem(R.drawable.yogurt_niuyouguo, "原味酸奶", "￥5", "/份"));
        rightDataList.add(new TypeRightItem(R.drawable.yogurt_niuyouguo, "草莓酸奶", "￥6", "/份"));
        rightDataList.add(new TypeRightItem(R.drawable.yogurt_niuyouguo, "蓝莓酸奶", "￥7", "/份"));
        rightDataList.add(new TypeRightItem(R.drawable.yogurt_niuyouguo, "芒果酸奶", "￥8", "/份"));
        rightDataList.add(new TypeRightItem(R.drawable.yogurt_niuyouguo, "巧克力酸奶", "￥9", "/份"));
        rightDataList.add(new TypeRightItem(R.drawable.yogurt_niuyouguo, "抹茶酸奶", "￥10", "/份"));

        TypeRightAdapter rightAdapter = new TypeRightAdapter(
                getContext(),
                R.layout.type_right_list,
                rightDataList
        );
        typeRightList.setAdapter(rightAdapter);

        return view;
    }
}